package com.terrorism.sdk.utils;

import java.util.Calendar;

/**
 * @since Monday, June 02, 2014
 * @author hoangcaomobile
 *
 */
public class TimeUtils {
	
	// get current date and time: yyyy-mm-dd hh:mm:ss
		public static String getCurrentDateTime() {
			Calendar c = Calendar.getInstance();
			int year = c.get(Calendar.YEAR);
			int month = c.get(Calendar.MONTH) + 1;
			int date = c.get(Calendar.DATE);
			int hour = c.get(Calendar.HOUR_OF_DAY);
			int minute = c.get(Calendar.MINUTE);
			int second = c.get(Calendar.SECOND);
			return year + "-" + month + "-" + date + " " + hour + ":" + minute + ":" + second;
		}
		// --

		// get current date: yyyymmdd
		public static String getCurrentDate() {
			Calendar c = Calendar.getInstance();
			int y = c.get(Calendar.YEAR);
			int m = c.get(Calendar.MONTH) + 1;
			int d = c.get(Calendar.DATE);
			return Integer.toString(y) + Integer.toString(m) + Integer.toString(d);
		}
		// --

		// get current time: hh:mm:ss
		public static String getCurrentTime() {
			Calendar c = Calendar.getInstance();
			int h = c.get(Calendar.HOUR_OF_DAY);
			int m = c.get(Calendar.MINUTE);
			int s = c.get(Calendar.SECOND);
			return Integer.toString(h) + ":" + Integer.toString(m) + ":" + Integer.toString(s);
		}
		// --

		// split time
		public static String splitTime(String dateTime) {
			String[] s = dateTime.split(" ");
			return s[1];
		}
		// --

}
